package com.ruoyi.web.controller.system;

import java.text.ParseException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Profile;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TTables;
import com.ruoyi.system.service.ITTablesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 棋牌室桌子信息Controller
 * 
 * @author ruoyi
 * @date 2025-09-24
 */
@RestController
@RequestMapping("/system/tables")
@RequiredArgsConstructor
@Profile("druid")
public class TTablesController extends BaseController
{
    private final ITTablesService tTablesService;
    /**
     * 查询棋牌室桌子信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:tables:list')")
    @GetMapping("/list")
    public TableDataInfo list(TTables tTables) throws ParseException {
        startPage();
        List<TTables> list = tTablesService.selectTTablesList(tTables);
        return getDataTable(list);
    }

    /**
     * 导出棋牌室桌子信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:tables:export')")
    @Log(title = "棋牌室桌子信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TTables tTables) throws ParseException {
        List<TTables> list = tTablesService.selectTTablesList(tTables);
        ExcelUtil<TTables> util = new ExcelUtil<TTables>(TTables.class);
        util.exportExcel(response, list, "棋牌室桌子信息数据");
    }

    /**
     * 获取棋牌室桌子信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:tables:query')")
    @GetMapping(value = "/{uuid}")
    public AjaxResult getInfo(@PathVariable("uuid") String uuid)
    {
        return success(tTablesService.selectTTablesByUuid(uuid));
    }

    /**
     * 新增棋牌室桌子信息
     */
    @PreAuthorize("@ss.hasPermi('system:tables:add')")
    @Log(title = "棋牌室桌子信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TTables tTables)
    {
        return toAjax(tTablesService.insertTTables(tTables));
    }

    /**
     * 修改棋牌室桌子信息
     */
    @PreAuthorize("@ss.hasPermi('system:tables:edit')")
    @Log(title = "棋牌室桌子信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TTables tTables)
    {
        return toAjax(tTablesService.updateTTables(tTables));
    }

    /**
     * 删除棋牌室桌子信息
     */
    @PreAuthorize("@ss.hasPermi('system:tables:remove')")
    @Log(title = "棋牌室桌子信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{uuids}")
    public AjaxResult remove(@PathVariable String uuids)
    {
        return toAjax(tTablesService.deleteTTablesByUuid(uuids));
    }
}
